package com.woniu.goodsservice.service.impl;

import com.woniu.goodsservice.dto.GoodsResultDTO;
import com.woniu.goodsservice.entity.Goods;
import com.woniu.goodsservice.dao.GoodsDao;
import com.woniu.goodsservice.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
    @Resource
    private GoodsDao goodsDao;

    @Override
    public Goods queryById(Integer id) {
        return goodsDao.queryById(id);
    }

    @Override
    public List<Goods> queryAllByLimit(int offset, int limit) {
        return goodsDao.queryAllByLimit(offset, limit);
    }
   
     @Override
    public List<Goods> findAll() {
        return goodsDao.findAll();
    }

    @Override
    public Goods insert(Goods goods) {
        goodsDao.insert(goods);
        return goods;
    }

    @Override
    public Goods update(Goods goods) {
        goodsDao.update(goods);
        return queryById(goods.getId());
    }

    @Override
    public boolean deleteById(Integer id) {
        return goodsDao.deleteById(id) > 0;
    }



    @Override
    public List<Goods> selectGoodsDataByPage(Integer currentPage, Integer pageSize, GoodsResultDTO goodsResultDTO) {


        return goodsDao.selectGoodsDataByPage(currentPage,pageSize,goodsResultDTO);
    }

    @Override
    public Goods selectGoodsDataById(Integer id) {
       Goods goods= goodsDao.selectGoodsDataById(id);
        return goods ;
    }

    @Override
    public void updateStatus(Integer newStatus, Integer goodsId) {
        goodsDao.updateStatus(newStatus,goodsId);
    }

    @Override
    public Goods queryByGoodsid(Integer goodsid) {
        return goodsDao.queryByGoodsid(goodsid);
    }
}